<?php

/**
 * Add your description here
 * 
 * @author 
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

class Default_Model_DbTable_Users extends Zend_Db_Table_Abstract
{
        /**
         * $_name - name of database table
         *
         * @var string
         */
	protected $_name='users';

        /**
         * $_id - this is the primary key of users table
         *        int(11)         
         *
         * @var int         
         */
	protected $_id='id';

        public function countAllRows() {
            $query = $this->select()->from($this->_name, 'count(*) as all_count');
            $numRows = $this->fetchRow($query);
            return $numRows['all_count'];
        }

        public function isUsernameExists($username) {
            $query = $this->select()->from($this->_name,'count(*) as all_count')->where('username = \''.addslashes($username).'\'');
            $numRows = $this->fetchRow($query);
            return $numRows['all_count']>0;
        }


}


